import os
import torch
import numpy as np


def mkdirs(paths):
    """
    创建多个或者单个文件夹
    :param paths: 文件夹路径，如果是多个文件夹，需要用list包裹
    :return: None
    :author: chaoshangcs(github)
    """
    if isinstance(paths, list) and not isinstance(paths, str):
        for path in paths:
            mkdir(path)
    else:
        mkdir(paths)


def mkdir(path):
    """
    创建单个文件夹
    :param path: 文件夹路径
    :return: None
    :author: chaoshangcs(github), qms
    """
    if not os.path.exists(path):
        os.makedirs(path)
    assert os.path.isdir(path), '%s is not a valid directory' % path


def get_now_time():
    """
    获取当前时间
    :param None
    :return: 当前时间字符串
    :author: qms
    """
    import datetime
    return datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S')


def init_random_seed(seed):
    """
    初始化随机种子
    :param seed: 随机种子
    :return: None
    :author: qms
    """
    torch.manual_seed(seed)
    np.random.seed(seed)
